<template>
  <aside class="sidebar">
    <nav class="menu">
      <router-link v-if="role === 'user'" to="/GameLibrary" class="menu-item" active-class="active">🎮 游戏库</router-link>
      <router-link v-if="role === 'user'" to="/GameMerch" class="menu-item" active-class="active">🛍️ 游戏周边</router-link>
      <router-link v-if="role === 'admin'" to="/GameManagement" class="menu-item" active-class="active">🎮 游戏管理</router-link>
      <router-link v-if="role === 'admin'" to="/GameMerchManagement" class="menu-item" active-class="active">🛍️ 游戏周边管理</router-link>
    </nav>
  </aside>
</template>

<script setup>
  // 从localStorage里拿角色信息
  const role = localStorage.getItem("role");

</script>

<style scoped>
.sidebar {
  width: 180px;
  min-height: 100vh;
  background: linear-gradient(135deg, #232946 80%, #181a20 100%);
  color: white;
  position: fixed;
  left: 0;
  top: 0;
  padding: 60px 12px 24px 12px;
  box-shadow: 0 8px 32px #23294644, 2px 0 6px rgba(0, 0, 0, 0.18);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  border-radius: 18px 0 0 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border-right: 2px solid #232946;
}

.logo {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 36px;
  text-align: center;
  color: #fff;
  word-break: break-all;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-top: 18px;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 8px;
  color: #b0b3b8;
  text-decoration: none;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 1px;
  background: rgba(35,41,70,0.92);
  box-shadow: 0 1px 6px #23294622;
  transition: background 0.3s, color 0.3s, box-shadow 0.3s, transform 0.2s;
  position: relative;
  overflow: hidden;
}

.menu-item:hover {
  background: linear-gradient(90deg, #4e8cff 0%, #232946 100%);
  color: #fff;
  box-shadow: 0 4px 16px #4e8cff55, 0 0 8px #4e8cff88;
  transform: scale(1.04);
}

.menu-item.active, .menu-item.router-link-exact-active {
  background: linear-gradient(90deg, #4e8cff 0%, #232946 100%);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 16px #4e8cff55, 0 0 12px #4e8cff88;
  border: 2px solid #4e8cff;
}

@media (max-width: 900px) {
  .sidebar {
    width: 100vw;
    min-width: 0;
    max-width: 100vw;
    border-radius: 0 0 18px 18px;
    border-right: none;
    border-bottom: 2px solid #232946;
    flex-direction: row;
    padding: 12px 0 12px 0;
    box-shadow: 0 4px 16px #23294633;
    position: static;
  }
  .menu {
    flex-direction: row;
    gap: 12px;
    margin-top: 0;
    width: 100vw;
    justify-content: center;
  }
  .menu-item {
    font-size: 16px;
    padding: 10px 8px;
    min-width: 80px;
  }
}
</style>